//
//  CMDBSearchManager.swift
//  CMDB
//
//  Created by 王磊 on 17/4/13.
//  Copyright © 2017年 CMDB. All rights reserved.
//

import UIKit

class CMDBSearchManager: NSObject {
    
    static let getInstance: CMDBSearchManager = CMDBSearchManager()
    
    private override init() {
        super.init()
        
    }
    
}
extension CMDBSearchManager: CMDBSearchManagerDelegate {}
// MARK: 搜索影人
extension CMDBSearchManager {
    
    func searchUser(searchUserParam: CMDBSearchUserParam, handler: CMDBSearchUserHandler, error: CMDBHttpErrorHandler, failure: CMDBHttpFailureHandler) {
        
        CMDBHttpManager.getInstance.request(searchUserParam.URLString(), param: searchUserParam.keyValues, success: { (sysTime, data, page) in
            
            let searchUser = CMDBSearchUserBean.objectWithKeyValues(data as! NSDictionary) as! CMDBSearchUserBean
            handler(searchUser: searchUser)
            
            }, error: error, failure: failure)
        
    }
}
// MARK: 搜索作品
extension CMDBSearchManager {
    
    func searchWorks(searchWorksParam: CMDBSearchWorksParam, handler: CMDBSearchWorksHandler, error: CMDBHttpErrorHandler, failure: CMDBHttpFailureHandler) {
        
        CMDBHttpManager.getInstance.request(searchWorksParam.URLString(), param: searchWorksParam.keyValues, success: { (sysTime, data, page) in
            
            let searchWorks = CMDBSearchWorksBean.objectWithKeyValues(data as! NSDictionary) as! CMDBSearchWorksBean
            
            handler(serchWorks: searchWorks)
            
            }, error: error, failure: failure)
    }
}
// MARK: 搜索条件

extension CMDBSearchManager {
    
    func searchCondition(searchConditionParam: CMDBSearchConditionParam, handler: CMDBSearchConditionHandler, error: CMDBHttpErrorHandler, failure: CMDBHttpFailureHandler) {
        
        CMDBHttpManager.getInstance.request(searchConditionParam.URLString(), param: searchConditionParam.keyValues, success: { (sysTime, data, page) in
            
            let searchCondition = CMDBSearchConditionBean.objectWithKeyValues(data as! NSDictionary) as! CMDBSearchConditionBean
            
            handler(searchCondition: searchCondition)
            
            }, error: error, failure: failure)
    }
}


